/**
 * file
 */
package com.tdkj.action.front.member;

import java.util.List;

import com.tdkj.action.BaseAction;
import com.tdkj.model.user.BeanUser;
import com.tdkj.model.user.BeanValidateEmil;

/**
 * 
 * FileName: ValidateEmailAction.java
 * 
 * @Description: TODO邮件验证
 * 
 *               All rights Reserved, Designed By ZTE-ITS
 * 
 *               Copyright: Copyright(C) 2010-2011
 * 
 *               Company 天成科技有限公司
 * 
 * @author: 李兴建
 * 
 * @version V1.0
 * 
 *          Createdate: 2012-8-19 下午08:08:24
 * 
 * 
 * 
 *          Modification History:
 * 
 *          Date Author Version Discription
 * 
 * 
 * 
 * 
 * 
 *          
 *          ----------------------------------------------------------------------
 *          -------------
 * 
 *          2012-8-19 李兴建 1.0 1.0
 * 
 *          Why & What is modified: <修改原因描述>
 */
public class ValidateEmailAction extends BaseAction {

	private static final long serialVersionUID = -8243643147000379838L;

	private String randomStr;

	/**
	 * 
	 */
	public ValidateEmailAction() {
		// TODO Auto-generated constructor stub
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		List<BeanValidateEmil> list = this.getBaseService().findByProperty("randomStr", randomStr, BeanValidateEmil.class);
		if (list.size() < 1) {
			// 验证失败
			return "failure";
		} else {
			// 验证成功
			BeanValidateEmil beanValidateEmiltemp = list.get(0);
			BeanUser userTemp = beanValidateEmiltemp.getUser();
			userTemp.setVerificationEmail(true);
			this.getBaseService().saveOrUpdate(userTemp, BeanUser.class);
			this.getBaseService().delete(beanValidateEmiltemp);

		}
		return "success";
	}

	/**
	 * @return the randomStr
	 */
	public String getRandomStr() {
		return randomStr;
	}

	/**
	 * @param randomStr
	 *            the randomStr to set
	 */
	public void setRandomStr(String randomStr) {
		this.randomStr = randomStr;
	}

}
